<template>
  <aside :class="['aui-sidebar', 'aui-sidebar--skin', {'aui-sidebar--isShow': $store.state.sidebarIsShow}]">
    <div class="aui-sidebar__inner">
      <el-menu
        :default-active="$store.state.sidebarMenuActiveName"
        :unique-opened="true"
        :collapse-transition="false"
        mode="vertical"
        @open="open"
        @close="close"
        ref="menu"
        class="aui-sidebar__menu">
        <sub-menu v-for="(menu, index) in $store.state.sidebarMenuList" :key="menu.id" :menu="menu" class="item" :class="`item-${index}`" />
      </el-menu>
    </div>
  </aside>
</template>

<script>
import SubMenu from './main-sidebar-sub-menu'
export default {
  data () {
    return {
      defaultIndex: ''
    }
  },
  components: {
    SubMenu
  },
  created () {
    this.$store.state.sidebarMenuList = window.SITE_CONFIG['menuList']
  },
  mounted () {
    this.$nextTick(() => {
      this.$refs.menu.open(this.$store.state.sidebarMenuList[0].id)
    })
  },
  methods: {
    open (index, indexPath) {
      this.defaultIndex = index
      if (this.defaultIndex !== this.$store.state.sidebarMenuList[0].id) {
        this.$store.state.sidebarIsShow = true
        this.$store.state.bgIsShow = false
      } else {
        this.$store.state.sidebarIsShow = false
        this.$store.state.bgIsShow = true
      }
    },
    close (index, indexPath) {
      if (indexPath.length === 1) {
        this.$refs.menu.open(this.defaultIndex)
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.aui-sidebar{
  overflow: visible;
  z-index: 9999;
  top: 77px;
  left: 14px;
  /deep/.aui-sidebar__menu{
    height: 100%;
  }
}
/deep/.aui-sidebar__inner{
  overflow: visible;
}
/deep/.item.is-opened {
  height: 100%;
  overflow: hidden;
  >.el-menu{
    overflow-y: scroll;
    width: 250px;
    height: 100%;
  }
  >.el-submenu__title{
    background: rgba(255,255,255,0.3) !important;
  }
}
/deep/.is-opened{
  >.el-submenu__title{
    color: #fff !important;
  }
}
/deep/.item>.el-menu{
  transition: 0s !important;
}
/deep/.el-submenu__title:focus,/deep/.el-menu-item:focus,/deep/.el-submenu__title:hover,/deep/.el-menu-item:hover{
  background: transparent;
}
/deep/.item>.el-submenu__title{
  position: fixed;
  z-index: 9999;
  top: 18px;
  color: #FFFFFF;
  font-size: 20px;
  border-radius: 26px;
  height: 40px;
  display: flex;
  align-items: center;
  &:hover{
    background: transparent;
  }
  .icon-svg{
    height: 20px;
  }
  i:before{
    display: none;
  }
}
/deep/.item>ul li{
  color: #88A6FF;
  font-size: 18px;
  .el-submenu__title{
    color: #88A6FF;
    font-size: 18px;
  }
}
@for $i from 0 through 17
{
  /deep/.item-#{$i}>.el-submenu__title
  {
    left:((150px * $i) + 350px);
  }
}

.aui-sidebar--skin{
  background: #24429E;
  border-radius: 10px;
  height: 0;
  /deep/.el-menu{
    background-color: transparent;
    .el-menu-item.is-active{
      color: #fff;
    }
  }
}
.aui-sidebar--isShow{
  height: calc(100vh - 87px);
}
/deep/.item>ul>li>ul{
  background-color: #27398E !important;
}
/deep/.item>ul>li>ul>li{
  font-size: 16px;
  &.is-active{
    >.circle{
      background-color: #909EC5;
    }
  }
  >.circle{
    display: inline-block;
    margin-right: 15px;
  }
  >.el-submenu__title{
    font-size: 16px;
    .icon-svg,i{
      display: none;
    }
    >.circle{
      display: inline-block;
      margin-right: 15px;
    }
  }
}
</style>
